<template>
  <el-menu
    :default-active="curPath"
    :mode="mode"
    class="el-menu-vertical-demo"
    background-color="#f6f6f6"
    text-color="#666"
    router
    active-text-color="#2d90f7">
    <div v-for="(item, index) in menuList" :key="index">
      <el-menu-item v-if="item.children && item.children.length === 1" v-show="!item.children[0].meta.hideMenu" :index="'/'+item.children[0].path">
        <i :class="item.children[0].meta.icon"></i>
        <span slot="title">{{ item.children[0].meta.title }}</span>
      </el-menu-item>
      <el-submenu :index="item.meta.index" v-if="item.children && item.children.length > 1">
        <template slot="title">
          <i :class="item.meta.icon"></i>
          <span>{{ item.meta.title }}</span>
        </template>
        <el-menu-item-group>
          <el-menu-item v-for="(citem, cindex) in item.children" :key="cindex" :index="'/'+citem.path">{{ citem.meta.title }}</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </div>
  </el-menu>
</template>

<script>
export default {
  props: {
    mode: {
      type: String,
      default: 'vertical' // horizontal
    }
  },
  components: {
  },
  data () {
    return {
    }
  },
  computed: {
    menuList () {
      return this.$store.state.menu.menuList
    },
    curPath () {
      return this.$route.path
    }
  },
  methods: {
  },
  watch: {
    // curPath (v) {
    //   console.log('v:', v)
    // }
  }
}
</script>

<style lang="less" scoped>
</style>
